FROM hypriot/rpi-python
MAINTAINER chiron

# install phantomjs
COPY sources.list /etc/apt/sources.list
RUN mkdir -p ~/.pip
COPY pip.conf ~/.pip/pip.conf
RUN sudo rm -rf /etc/apt/sources.list.d/*

RUN sudo apt-get update
RUn sudo apt-get install -y build-essential g++ flex bison gperf ruby perl libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev libpng-dev libjpeg-dev python libx11-dev libxext-dev git python-pip libcurl4-openssl-dev libmysqld-dev libpq-dev python-dev libevent-dev gcc libxml2 libxml2-dev libxslt1-dev libffi-dev libicu48 libssl1.0.0 gstreamer0.10-alsa fontconfig freetype2-demos

RUN mkdir -p /opt/mysql-connector-python
ADD ./mysql-connector-python-1.0.11/ /opt/mysql-connector-python/
RUN cd /opt/mysql-connector-python && python setup.py install


RUN cd /opt/ && sudo git clone https://gitee.com/hades_c/phantomjs-raspberrypi.git \
    && cd /opt/phantomjs-raspberrypi \
    && git checkout 1.9.8

RUN sudo chmod -x /opt/phantomjs-raspberrypi/bin/phantomjs \
    && sudo chmod 775 /opt/phantomjs-raspberrypi/bin/phantomjs \
    && sudo ln -s /opt/phantomjs-raspberrypi/bin/phantomjs /usr/bin/

#RUN python -m pip install --upgrade pip

RUN pip install -U setuptools -i http://pypi.douban.com/simple
RUN pip install -U wheel -i http://pypi.douban.com/simple

RUN cd /opt/ && git clone https://gitee.com/hades_c/pyspider.git
COPY requirements.txt /opt/pyspider/requirements.txt
# install requirements
RUN pip install -r /opt/pyspider/requirements.txt -i http://pypi.douban.com/simple

# run test
WORKDIR /opt/pyspider
RUN pip install -i http://pypi.douban.com/simple -e .

VOLUME ["/opt/pyspider"]
ENTRYPOINT ["pyspider"]

EXPOSE 5000 23333 24444 25555
